package cn.lili.modules.auth.client;


import cn.lili.common.security.AuthUser;
import cn.lili.common.security.enums.SceneEnums;
import cn.lili.common.security.token.Token;
import cn.lili.modules.auth.fallback.TokenGenerateFallback;
import cn.lili.modules.constant.ServiceConstant;
import cn.lili.modules.member.entity.dos.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * token客户端
 */
@FeignClient(path = "${server.servlet.context-path}", name = ServiceConstant.AUTH_SERVICE, contextId = "auth-service-statistics", fallback = TokenGenerateFallback.class)
public interface AuthClient {


    /**
     * 创建token
     *
     * @param user     用户
     * @param longTerm 长期有效
     * @return
     */
    @GetMapping("/feign/auth/create")
    Token createToken(User user, @RequestParam boolean longTerm);

    /**
     * 刷新token
     *
     * @param refreshToken
     * @return
     */
    @GetMapping("/feign/auth/refresh")
    Token refreshToken(String refreshToken);


    /**
     * 登出
     *
     * @param sceneEnums token角色类型
     */
    @GetMapping("/feign/member/logout")
    void logout(@RequestParam SceneEnums sceneEnums);

    /**
     * 重置会员的权限map
     *
     * @param authUser 用户信息
     */
    @PutMapping("/feign/member/permission/reset")
    void resetUserPermissionMap(@RequestBody AuthUser authUser);
}
